
using System;
using System.Text;
using System.Web;

public static class program
{
    public static void Main(string[] args)
    {
        Encoding enc = null;
        if(args != null && args.Length > 0)
        {
            try
            {
                enc = Encoding.GetEncoding(args[0]);
            }
            catch { }
        }
        if(enc == null) enc = Encoding.UTF8;

        string s = null;
        while((s = Console.ReadLine()) != null)
        {
            Console.WriteLine(HttpUtility.UrlEncode(s, enc));
        }
    }
}

